/*package com.troila.cloud.simplify.service;




import java.io.Serializable;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import com.troila.cloud.simplify.model.RedisKeyDto;

@Service
public class RedisService  {

	@Autowired
    private RedisTemplate redisTemplate;

    @SuppressWarnings("unchecked")
	public void addData(final RedisKeyDto redisKeyDto) {
        redisTemplate.execute(new RedisCallback<Object>() {
            public Object doInRedis(RedisConnection connection)
                    throws DataAccessException {
                connection.set(
                        redisTemplate.getStringSerializer().serialize(redisKeyDto.getKeys()),
                        redisTemplate.getStringSerializer().serialize(redisKeyDto.getValues())
                );
                return null;
            }
        });
    }

    @SuppressWarnings("unchecked")
	public void delete(final RedisKeyDto redisKeyDto) {
        redisTemplate.execute(new RedisCallback<Object>() {
            public Object doInRedis(RedisConnection connection)
                    throws DataAccessException {
                connection.del(redisTemplate.getStringSerializer().serialize(redisKeyDto.getKeys()));
                return null;
            }
        });
    }

    @SuppressWarnings("unchecked")
	public RedisKeyDto redisGet(final RedisKeyDto redisKeyDto) {
        return (RedisKeyDto) redisTemplate.execute(new RedisCallback<RedisKeyDto>() {
            public RedisKeyDto doInRedis(RedisConnection connection) throws DataAccessException {
                byte[] key = redisTemplate.getStringSerializer().serialize(redisKeyDto.getKeys());
                if (connection.exists(key)) {
                    byte[] value = connection.get(key);
                    //从redis中取出的需要反序列化--- deserialize
                    String redisValue=(String) redisTemplate.getStringSerializer().deserialize(value);
                    RedisKeyDto re=new RedisKeyDto();
                    re.setKeys(redisKeyDto.getKeys());
                    re.setValues(redisValue);
                    return re;
                }
                return null;
            }
        });
    }

    @SuppressWarnings("unchecked")
	public void addRedisData(final RedisKeyDto redisKeyDto, final int outTime) {
        redisTemplate.execute(new RedisCallback<Object>() {
            public Object doInRedis(RedisConnection connection)
                    throws DataAccessException {
                connection.set(
                        redisTemplate.getStringSerializer().serialize(redisKeyDto.getKeys()),
                        redisTemplate.getStringSerializer().serialize(redisKeyDto.getValues())
                );
                connection.expire(redisTemplate.getStringSerializer().serialize(redisKeyDto.getKeys()),outTime);
                return null;
            }
        });
    }

    @SuppressWarnings("unchecked")
   	public void updateRedisDataKeepOnTime(final RedisKeyDto redisKeyDto) {
           redisTemplate.execute(new RedisCallback<Object>() {
               public Long doInRedis(RedisConnection connection)
                       throws DataAccessException {
                   Long time = connection.ttl(
                           redisTemplate.getStringSerializer().serialize(redisKeyDto.getKeys())
                   );
                   connection.set(
                           redisTemplate.getStringSerializer().serialize(redisKeyDto.getKeys()),
                           redisTemplate.getStringSerializer().serialize(redisKeyDto.getValues())
                   );
                   connection.expire(redisTemplate.getStringSerializer().serialize(redisKeyDto.getKeys()),time);
                   return time;
               }
           });
       }

    @SuppressWarnings("rawtypes")
	public RedisTemplate getRedisTemplate() {
        return redisTemplate;
    }

    public void setRedisTemplate(RedisTemplate redisTemplate) {
        this.redisTemplate = redisTemplate;
    }
}*/